﻿<Application
	x:Class="AppManager.App"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:s="clr-namespace:System;assembly=mscorlib"
	xmlns:am="clr-namespace:AppManager"
    xmlns:amc="clr-namespace:AppManager.Controls"
	xmlns:с="clr-namespace:CommonLib;assembly=CommonLib"
    ShutdownMode="OnExplicitShutdown">

	<Application.Resources>

        <Style TargetType="{x:Type amc:BorderedPanel}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type amc:BorderedPanel}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="*"></RowDefinition>
                                <RowDefinition Height="6"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Label 
                                x:Name="Header"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"
                                Grid.Row="0"
                                Foreground="{TemplateBinding Foreground}"
                                Padding="4,0,4,0"
                                Margin="8,0,0,0" />
                                <ContentPresenter
                                    Grid.Row="1" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


        <Style
			TargetType="Separator"
			x:Key="SpecialSeparator">
			<Style.Resources>
				<ResourceDictionary />
			</Style.Resources>
			<Setter
				Property="UIElement.SnapsToDevicePixels">
				<Setter.Value>
					<s:Boolean>True</s:Boolean>
				</Setter.Value>
			</Setter>
			<Setter
				Property="FrameworkElement.Height">
				<Setter.Value>
					<s:Double>1</s:Double>
				</Setter.Value>
			</Setter>
			<Setter
				Property="FrameworkElement.Margin">
				<Setter.Value>
					<Thickness>4,4,4,4</Thickness>
				</Setter.Value>
			</Setter>
			<Setter
				Property="Control.Template">
				<Setter.Value>
					<ControlTemplate
						TargetType="Separator">
						<Grid
							Background="#FF9ABAE6"
							Height="1"
							SnapsToDevicePixels="True" />
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style
			TargetType="Menu"
			x:Key="SpecialMenu">
			<Style.Resources>
				<ResourceDictionary />
			</Style.Resources>
			<Setter
				Property="FrameworkElement.OverridesDefaultStyle">
				<Setter.Value>
					<s:Boolean>True</s:Boolean>
				</Setter.Value>
			</Setter>
			<Setter
				Property="UIElement.SnapsToDevicePixels">
				<Setter.Value>
					<s:Boolean>True</s:Boolean>
				</Setter.Value>
			</Setter>
			<Setter
				Property="Control.Template">
				<Setter.Value>
					<ControlTemplate
						TargetType="Menu">
						<Border
							BorderThickness="0,0,0,1"
							BorderBrush="#FFAAAAAA">
							<Border.Background>
								<LinearGradientBrush
									StartPoint="0,0"
									EndPoint="0,1">
									<LinearGradientBrush.GradientStops>
										<GradientStop
											Color="#FFDFE9F6"
											Offset="0" />
										<GradientStop
											Color="#FFC7D8EE"
											Offset="1" />
									</LinearGradientBrush.GradientStops>
								</LinearGradientBrush>
							</Border.Background>
							<ItemsPresenter
								SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style
			TargetType="ContextMenu"
			x:Key="SpecialContextMenu">
			<Style.Resources>
				<ResourceDictionary />
			</Style.Resources>
			<!--<Setter
				Property="FrameworkElement.OverridesDefaultStyle">
				<Setter.Value>
					<s:Boolean>True</s:Boolean>
				</Setter.Value>
			</Setter>-->
			<Setter
				Property="UIElement.SnapsToDevicePixels">
				<Setter.Value>
					<s:Boolean>True</s:Boolean>
				</Setter.Value>
			</Setter>
			<Setter
				Property="Control.Template">
				<Setter.Value>
					<ControlTemplate
						TargetType="ContextMenu">
						<Border
							Name="Border"
							BorderThickness="0,0,0,1"
							BorderBrush="#FFAAAAAA">
							<Border.Background>
								<LinearGradientBrush
									StartPoint="0,0"
									EndPoint="0,1">
									<LinearGradientBrush.GradientStops>
										<GradientStop
											Color="#FFDFE9F6"
											Offset="0" />
										<GradientStop
											Color="#FFC7D8EE"
											Offset="1" />
									</LinearGradientBrush.GradientStops>
								</LinearGradientBrush>
							</Border.Background>
							<ItemsPresenter
								SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
						</Border>
						<ControlTemplate.Triggers>
							<Trigger
								Property="MenuItem.IsHighlighted"
								Value="True">
								<Setter
									Property="Background"
									TargetName="Border"
									Value="Transparent">
									<!--<Setter.Value>
										<SolidColorBrush>#FF97B2D7</SolidColorBrush>
									</Setter.Value>-->
								</Setter>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style
			TargetType="MenuItem"
			x:Key="SpecialMenuItem">
			<Setter
				Property="Background"
				Value="Red"
			/>
			<Style.Triggers>
				<Trigger
					Property="MenuItem.Role"
					Value="{x:Static MenuItemRole.TopLevelHeader}">
					<Setter
						Property="Control.Template"
						Value="{DynamicResource SpecialTopLevelHeader}"
						/>
				</Trigger>
				<Trigger
					Property="MenuItem.Role"
					Value="{x:Static MenuItemRole.TopLevelItem}">
					<Setter
						Property="Control.Template"
						Value="{DynamicResource SpecialTopLevelItem}"
						/>
				</Trigger>
				<Trigger
					Property="MenuItem.Role"
					Value="{x:Static MenuItemRole.SubmenuHeader}">
					<Setter
						Property="Control.Template"
						Value="{DynamicResource SpecialSubmenuHeader}"
						/>
				</Trigger>
				<Trigger
					Property="MenuItem.Role"
					Value="{x:Static MenuItemRole.SubmenuItem}">
					<Setter
						Property="Control.Template"
						Value="{DynamicResource SpecialSubmenuItem}"
						/>
				</Trigger>
			</Style.Triggers>
			<Style.Resources>
				<ResourceDictionary />
			</Style.Resources>
		</Style>
		
		<ControlTemplate
			TargetType="MenuItem"
			x:Key="SpecialSubmenuHeader">
			<Border
				Name="Border">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition
							Width="Auto"
							MinWidth="17"
							SharedSizeGroup="Icon" />
						<ColumnDefinition
							Width="*" />
						<ColumnDefinition
							Width="Auto"
							SharedSizeGroup="Shortcut" />
						<ColumnDefinition
							Width="13" />
					</Grid.ColumnDefinitions>
					<ContentPresenter
						Content="{TemplateBinding MenuItem.Icon}"
						ContentSource="Icon"
						Name="Icon"
						Margin="6,0,6,0"
						HorizontalAlignment="Center"
						VerticalAlignment="Center" />
					<ContentPresenter
						RecognizesAccessKey="True"
						Content="{TemplateBinding HeaderedContentControl.Header}"
						ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
						ContentSource="Header"
						Name="HeaderHost"
						Margin="0,4,0,4"
						TextElement.Foreground="#FF4971A3"
						Grid.Column="1" />
					<TextBlock
						Text="{TemplateBinding MenuItem.InputGestureText}"
						Foreground="#FF4971A3"
						Name="InputGestureText"
						Margin="5,2,2,2"
						Grid.Column="2" />
					<Path
						Data="M0,0L0,7 4,3.5z"
						Fill="#FF4971AA"
						Name="Arrow"
						HorizontalAlignment="Center"
						VerticalAlignment="Center"
						Grid.Column="3" />
					<Popup
						IsOpen="{TemplateBinding MenuItem.IsSubmenuOpen}"
						Placement="Right"
						HorizontalOffset="0"
						PopupAnimation="Fade"
						AllowsTransparency="True"
						Name="Popup"
						Focusable="False">
						<Border
							BorderThickness="1,1,1,1"
							BorderBrush="#FF9ABAE6"
							Name="SubmenuBorder"
							SnapsToDevicePixels="True">
							<Border.Background>
								<LinearGradientBrush
									StartPoint="0,0"
									EndPoint="0,1">
									<LinearGradientBrush.GradientStops>
										<GradientStop
											Color="#FFDFE9F6"
											Offset="0" />
										<GradientStop
											Color="#FFC7D8EE"
											Offset="1" />
									</LinearGradientBrush.GradientStops>
								</LinearGradientBrush>
							</Border.Background>
							<ItemsPresenter
								SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
						</Border>
					</Popup>
				</Grid>
			</Border>
			<ControlTemplate.Triggers>
				<Trigger
					Property="MenuItem.Icon">
					<Setter
						Property="UIElement.Visibility"
						TargetName="Icon">
						<Setter.Value>
							<x:Static
								Member="Visibility.Hidden" />
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<x:Null />
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="MenuItem.IsHighlighted">
					<Setter
						Property="Panel.Background"
						TargetName="Border"
						Value="Transparent">
						<!--<Setter.Value>
							<SolidColorBrush>#FF97B2D7</SolidColorBrush>
						</Setter.Value>-->
					</Setter>
					<Setter
						Property="TextElement.Foreground"
						TargetName="HeaderHost"
						Value="Red">
					</Setter>
					<Setter
						Property="TextElement.Foreground"
						TargetName="InputGestureText">
						<Setter.Value>
							<SolidColorBrush>#FFFFFFFF</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Setter
						Property="Shape.Fill"
						TargetName="Arrow">
						<Setter.Value>
							<SolidColorBrush>#FFFFFFFF</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>True</s:Boolean>
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="Window.AllowsTransparency"
					SourceName="Popup">
					<Setter
						Property="Border.CornerRadius"
						TargetName="SubmenuBorder">
						<Setter.Value>
							<CornerRadius>4,4,4,4</CornerRadius>
						</Setter.Value>
					</Setter>
					<Setter
						Property="Border.Padding"
						TargetName="SubmenuBorder">
						<Setter.Value>
							<Thickness>0,3,0,3</Thickness>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>True</s:Boolean>
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="UIElement.IsEnabled">
					<Setter
						Property="TextElement.Foreground"
						TargetName="HeaderHost">
						<Setter.Value>
							<SolidColorBrush>#FF888888</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Setter
						Property="TextElement.Foreground"
						TargetName="InputGestureText">
						<Setter.Value>
							<SolidColorBrush>#FF888888</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>False</s:Boolean>
					</Trigger.Value>
				</Trigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
		<ControlTemplate
			TargetType="MenuItem"
			x:Key="SpecialSubmenuItem">
			<Border
				Name="Border">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition
							Width="Auto"
							MinWidth="17"
							SharedSizeGroup="Icon" />
						<ColumnDefinition
							Width="*" />
						<ColumnDefinition
							Width="Auto"
							SharedSizeGroup="Shortcut" />
						<ColumnDefinition
							Width="13" />
					</Grid.ColumnDefinitions>
					<ContentPresenter
						Content="{TemplateBinding MenuItem.Icon}"
						ContentSource="Icon"
						Name="Icon"
						Margin="6,4,6,4"
						HorizontalAlignment="Center"
						VerticalAlignment="Center" />
					<Path
						Data="M0,2L0,4.8 2.5,7.4 7.1,2.8 7.1,0 2.5,4.6z"
						Fill="#FF4971AA"
						Name="CheckMark"
						FlowDirection="LeftToRight"
						Margin="4,0,6,0"
						VerticalAlignment="Center"
						Visibility="Hidden"
						SnapsToDevicePixels="False" />
					<ContentPresenter
						RecognizesAccessKey="True"
						Content="{TemplateBinding HeaderedContentControl.Header}"
						ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
						ContentSource="Header"
						Name="HeaderHost"
						Margin="0,4,0,4"
						TextElement.Foreground="#FF06326C"
						Grid.Column="1" />
					<TextBlock
						Text="{TemplateBinding MenuItem.InputGestureText}"
						Foreground="#FF4971A3"
						Name="InputGestureText"
						Margin="5,4,0,4"
						DockPanel.Dock="Right"
						Grid.Column="2" />
				</Grid>
			</Border>
			<ControlTemplate.Triggers>
				<Trigger
					Property="MenuItem.Icon">
					<Setter
						Property="UIElement.Visibility"
						TargetName="Icon">
						<Setter.Value>
							<x:Static
								Member="Visibility.Hidden" />
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<x:Null />
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="MenuItem.IsChecked">
					<Setter
						Property="UIElement.Visibility"
						TargetName="CheckMark">
						<Setter.Value>
							<x:Static
								Member="Visibility.Visible" />
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>True</s:Boolean>
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="MenuItem.IsCheckable">
					<Setter
						Property="UIElement.Visibility"
						TargetName="Icon">
						<Setter.Value>
							<x:Static
								Member="Visibility.Hidden" />
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>True</s:Boolean>
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="MenuItem.IsHighlighted">
					<Setter
						Property="Panel.Background"
						TargetName="Border"
						Value="Transparent">
						<!--<Setter.Value>
							<SolidColorBrush>#FF97B2D7</SolidColorBrush>
						</Setter.Value>-->
					</Setter>
					<Setter
						Property="TextElement.Foreground"
						TargetName="HeaderHost">
						<Setter.Value>
							<SolidColorBrush>#FFFFFFFF</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Setter
						Property="TextElement.Foreground"
						TargetName="InputGestureText">
						<Setter.Value>
							<SolidColorBrush>#FFFFFFFF</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>True</s:Boolean>
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="UIElement.IsEnabled">
					<Setter
						Property="TextElement.Foreground"
						TargetName="HeaderHost">
						<Setter.Value>
							<SolidColorBrush>#FF888888</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Setter
						Property="TextElement.Foreground"
						TargetName="InputGestureText">
						<Setter.Value>
							<SolidColorBrush>#FF888888</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>False</s:Boolean>
					</Trigger.Value>
				</Trigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
		<ControlTemplate
			TargetType="MenuItem"
			x:Key="SpecialTopLevelItem">
			<Border
				Name="Border">
				<Grid>
					<ContentPresenter
						RecognizesAccessKey="True"
						Content="{TemplateBinding HeaderedContentControl.Header}"
						ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
						ContentSource="Header"
						Margin="8,4,8,4" />
				</Grid>
			</Border>
			<ControlTemplate.Triggers>
				<Trigger
					Property="MenuItem.IsHighlighted">
					<Setter
						Property="Panel.Background"
						TargetName="Border"
						Value="Red">
						<!--<Setter.Value>
							<SolidColorBrush>#00FFFFFF</SolidColorBrush>
						</Setter.Value>-->
					</Setter>
					<Setter
						Property="Border.BorderBrush"
						TargetName="Border">
						<Setter.Value>
							<SolidColorBrush>#00FFFFFF</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>True</s:Boolean>
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="UIElement.IsEnabled">
					<Setter
						Property="TextElement.Foreground">
						<Setter.Value>
							<SolidColorBrush>#FF888888</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>False</s:Boolean>
					</Trigger.Value>
				</Trigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
		<ControlTemplate
			TargetType="MenuItem"
			x:Key="SpecialTopLevelHeader">
			<Border
				Name="Border">
				<Grid>
					<ContentPresenter
						RecognizesAccessKey="True"
						Content="{TemplateBinding HeaderedContentControl.Header}"
						ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
						ContentSource="Header"
						Margin="8,6,8,6"
						TextElement.Foreground="#FF06326C"
						/>
					<Popup
						IsOpen="{TemplateBinding MenuItem.IsSubmenuOpen}"
						Placement="Bottom"
						HorizontalOffset="1"
						PopupAnimation="Fade"
						AllowsTransparency="True"
						Name="Popup"
						Focusable="False">
						<Border
							BorderThickness="1,1,1,1"
							BorderBrush="#FF9ABAE6"
							Name="SubmenuBorder"
							SnapsToDevicePixels="True">
							<Border.Background>
								<LinearGradientBrush
									StartPoint="0,0"
									EndPoint="0,1">
									<LinearGradientBrush.GradientStops>
										<GradientStop
											Color="#FFDFE9F6"
											Offset="0" />
										<GradientStop
											Color="#FFC7D8EE"
											Offset="1" />
									</LinearGradientBrush.GradientStops>
								</LinearGradientBrush>
							</Border.Background>
							<ItemsPresenter
								SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
						</Border>
					</Popup>
				</Grid>
			</Border>
			<ControlTemplate.Triggers>
				<Trigger
					Property="MenuItem.IsSuspendingPopupAnimation">
					<Setter
						Property="Popup.PopupAnimation"
						TargetName="Popup">
						<Setter.Value>
							<x:Static
								Member="PopupAnimation.None" />
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>True</s:Boolean>
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="MenuItem.IsHighlighted">
					<Setter
						Property="Panel.Background"
						TargetName="Border"
						Value="Transparent">
						<!--<Setter.Value>
							<SolidColorBrush>#FF97B2D7</SolidColorBrush>
						</Setter.Value>-->
					</Setter>
					<Setter
						Property="Border.BorderBrush"
						TargetName="Border">
						<Setter.Value>
							<SolidColorBrush>#00FFFFFF</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>True</s:Boolean>
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="Window.AllowsTransparency"
					SourceName="Popup">
					<Setter
						Property="Border.CornerRadius"
						TargetName="SubmenuBorder">
						<Setter.Value>
							<CornerRadius>0,0,4,4</CornerRadius>
						</Setter.Value>
					</Setter>
					<Setter
						Property="Border.Padding"
						TargetName="SubmenuBorder">
						<Setter.Value>
							<Thickness>0,0,0,3</Thickness>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>True</s:Boolean>
					</Trigger.Value>
				</Trigger>
				<Trigger
					Property="UIElement.IsEnabled">
					<Setter
						Property="TextElement.Foreground">
						<Setter.Value>
							<SolidColorBrush>#FF888888</SolidColorBrush>
						</Setter.Value>
					</Setter>
					<Trigger.Value>
						<s:Boolean>False</s:Boolean>
					</Trigger.Value>
				</Trigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
		
		<ContextMenu
			x:Key="ItemMenu"
			Style="{DynamicResource SpecialContextMenu}"
			ItemContainerStyle="{DynamicResource SpecialMenuItem}"
			>
            <MenuItem Name="Run" />
            <MenuItem Name="RunAs" >
				<MenuItem.Icon>
					<Image Source="Resources/Firewall16.png"/>
				</MenuItem.Icon>
			</MenuItem>
			<MenuItem Name="RunWithArgs" />
            <Separator />
			<MenuItem Name="Edit" />
			<MenuItem Name="SetImage" />
            <MenuItem Name="RefreshImage" />
			<MenuItem Name="Rename" />
			<MenuItem Name="Delete" />
			<MenuItem Name="GoTo" />
            <Separator />
			<MenuItem x:Name="Cancel" Header="{x:Static с:CommStr.CANCEL}" />
		</ContextMenu>
		<ContextMenu
			x:Key="AppTypeMenu"
			Style="{DynamicResource SpecialContextMenu}"
			ItemContainerStyle="{DynamicResource SpecialMenuItem}"
			>
			<MenuItem Name="AddNewApp" Header="{x:Static am:Strings.MNU_ADD_APP}" />
			<MenuItem Name="AddAppType" Header="{x:Static am:Strings.MNU_ADD_APP_TYPE}" />
			<MenuItem Name="RenameAppType" Header="{x:Static am:Strings.MNU_ADD_APP_TYPE}" />
			<MenuItem Name="DeleteAppType" />
			<Separator />
			<MenuItem x:Name="AppTypeCancel" Header="{x:Static с:CommStr.CANCEL}" />
		</ContextMenu>
		<ContextMenu
			x:Key="AddAppTypeMenu"
			Style="{DynamicResource SpecialContextMenu}"
			ItemContainerStyle="{DynamicResource SpecialMenuItem}">
			<MenuItem
				x:Name="AddAppTypeATM"
				Header="{x:Static am:Strings.MNU_ADD_APP_TYPE}" />
			<Separator />
			<MenuItem
				x:Name="AppTypeMenuCancel"
				Header="{x:Static с:CommStr.CANCEL}" />
		</ContextMenu>

		<LinearGradientBrush
			x:Key="MainWindowBorder"
			EndPoint="348.806,530.234"
			StartPoint="81.194,33.766"
			MappingMode="Absolute">
			<GradientStop
				Color="#FFF8CF75"
				Offset="0" />
			<GradientStop
				Color="#FFBD8B1C"
				Offset="1" />
		</LinearGradientBrush>

	</Application.Resources>
</Application>
